#include<stdio.h>
#include<stdlib.h>
#include<signal.h>
#include<unistd.h>
#include<string.h>
#include<sys/types.h>
#include<sys/wait.h>


void SigHandlerNew(int signum , siginfo_t *info , void *myact)
{
	char *pszInfo = (char *)(info -> si_ptr);
	printf("Get: %d, info:%s \n",signum , pszInfo);	
}


int main(int argc , char* *argv)
{
	struct sigaction act;
	union sigval mysigval;
	int sig;
	char data[]="other info";
	
	if(argc < 2)
	{
		printf("usage:signnum\n");
		return -1;	
	}	

	mysigval.sival_ptr = data;
	sig = atoi(argv[1]);
	sigemptyset(&act.sa_mask);
	act.sa_sigaction = SigHandlerNew;
	act.sa_flags = SA_SIGINFO;
	sigaction( sig,&act , NULL );
	while(1)
	{
		printf("wait for the Signal \n");	
		sigqueue(getpid() , sig ,mysigval );
		sleep(2);
	}

	return 0;
}
